package com.resou.reader.bookstore.freeandfinish;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.resou.reader.R;
import com.resou.reader.api.entry.FinishedBookBean;

import java.util.List;

public class FinishBookAdapter extends BaseQuickAdapter<FinishedBookBean.BooksBean, BaseViewHolder> {
    public FinishBookAdapter(int layoutResId, @Nullable List<FinishedBookBean.BooksBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, FinishedBookBean.BooksBean item) {
        Glide.with(mContext).load(item.getCoverUrl() == null ? "" : item.getCoverUrl()).placeholder(R.mipmap.ic_place).into((ImageView) helper.getView(R.id.tvBookPic));
        helper.addOnClickListener(R.id.llContentOnclick)
                .setText(R.id.tvBookName, item.getNovelName() + "")
                .setText(R.id.tvAuthor, item.getAuthorName() + "")
                .setText(R.id.tvDes, item.getContent() + "");
        if (item.getParentCategoryName() != null && !item.getParentCategoryName().equals("null") && !item.getParentCategoryName().equals("")) {
            helper.getView(R.id.tvLabel).setVisibility(View.VISIBLE);
            helper.setText(R.id.tvLabel, item.getParentCategoryName() + "");
        } else {
            helper.getView(R.id.tvLabel).setVisibility(View.GONE);
        }
    }
}
